#include "homepage.h"
#include <QApplication>
#include <QPixmap>
#include <QSplashScreen>
#include <QLabel>
#include <QMovie>
#include <QCoreApplication>
#include <QTime>
#include <QProgressBar>
#include <QDesktopWidget>


void Sleep(int mSeconds)
{
    QTime dieTime = QTime::currentTime().addMSecs(mSeconds);
    while (QTime::currentTime() < dieTime)
    {
        QCoreApplication::processEvents(QEventLoop::AllEvents, 100);
    }
}

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QDesktopWidget *pDesk = QApplication::desktop();

    QProgressBar progressBar(pDesk);
    progressBar.setRange(0,100);
    progressBar.setWindowFlags(Qt::FramelessWindowHint);//去掉标题栏
    progressBar.resize(700,40);
    progressBar.setTextVisible(false);

    QPixmap pix(":/new/prefix1/picture_tubiao/kaiji.gif");
    QSplashScreen splash(pix);
    //splash.setWindowOpacity(0.8); // 设置窗口透明度
    QLabel label(&splash);
    QMovie mv(":/new/prefix1/picture_tubiao/kaiji.gif");
    label.setMovie(&mv);
    mv.start();

    splash.show();
    progressBar.move(333,610);

    //progressBar.show();
    splash.setCursor(Qt::BlankCursor);
    for(int i=0; i<=4000; i+=mv.speed())
    {
        QCoreApplication::processEvents();
        progressBar.setValue(i/30);
        Sleep(mv.speed());
    }


    HomePage w(pDesk);
    w.move((pDesk->width() - w.width()) / 2, (pDesk->height() - w.height()) / 2);
    w.show();

    splash.finish(&w);
    return a.exec();
}
